package io.file;

import java.io.File;
import java.io.IOException;

public class FileCreate {
    public static void main(String[] args) {
        FileCreate fileCreate = new FileCreate();
        fileCreate.createFile();

    }

    public void createFile() {
        String parent = "D:/Test/";
        String fileName = "create1.txt";
        File file = new File(parent);
        try {
            if (!file.exists()) {
                file.mkdirs();//创建多级目录
            }
            File file1 = new File(parent, fileName);
            file1.createNewFile();//创建文件
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
